/**
 * 项目的启动入口
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'

// 加载 element 组件库
import ElementUI from 'element-ui'

// 加载 element 组件库样式
import 'element-ui/lib/theme-chalk/index.css'

// 加载全局样式文件
import './styles/index.less'

import store from './store'

import {loadingText}from '@/config/settings'
// 导入全局样式
import {
  Notification
  ,Message,
  Loading
} from 'element-ui'


// 引入插件
import './plugins/vabVerify'





Vue.config.productionTip = false

// 全局注册element组件库
Vue.use(ElementUI)

// 全局提示
Vue.prototype.$baseNotify = (message, title, type, position) => {
  Notification({
    title: title,
    message: message,
    position: position || 'top-right',
    type: type || 'success',
    duration: 3000//全局提示显示的时间
  })
}

 /* 全局Message */
 Vue.prototype.$baseMessage = (message, type) => {
  Message({
    offset: 60,
    showClose: true,
    message: message,
    type: type,
    dangerouslyUseHTMLString: true,
    duration: 3000,
  })
}


/* 全局加载层 */
Vue.prototype.$baseLoading = (index, text) => {
  let loading
  if (!index) {
    loading = Loading.service({
      lock: true,
      text: text || loadingText,
      background: 'hsla(0,0%,100%,.6)',
    })
  } else {
    loading = Loading.service({
      lock: true,
      text: text || loadingText,
      spinner: 'vab-loading-type' + index,
      background: 'hsla(0,0%,100%,.6)',
    })
  }
  return loading
}
/* 全局多彩加载层 */
Vue.prototype.$baseColorfullLoading = (index, text) => {
  let loading
  if (!index) {
    loading = Loading.service({
      lock: true,
      text: text || loadingText,
      spinner: 'dots-loader',
      background: 'hsla(0,0%,100%,.8)',
    })
  } else {
    switch (index) {
      case 1:
        index = 'dots'
        break
      case 2:
        index = 'gauge'
        break
      case 3:
        index = 'inner-circles'
        break
      case 4:
        index = 'plus'
        break
    }
    loading = Loading.service({
      lock: true,
      text: text || loadingText,
      spinner: index + '-loader',
      background: 'hsla(0,0%,100%,.8)',
    })
  }
  return loading
}




// 创建vue实例
// 把 router 配置到根实例中
// 通过 render 方法把 App 根组件渲染到 #app 入口节点
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
